home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
stats
/
nonlin31.arj
/
PIECE.NLR
< prev
next >
Wrap
Text File
|
1994-01-23
|
2KB
|
72 lines
/*
* Fit a piecewise linear function that pivots at X=5.
* When X is less than 5, the slope is B1.
* When X is greater than or equal to 5, the slope is B2.
* B0 is the Y value when X=5 (i.e., at the pivot point).
*/
Title "Piecewise linear function";
Variables X,Y;
Parameter B0;
Parameter B1;
Parameter B2;
Constant Pivot=5; // X value at which bend occurs
if (x < Pivot) {
Function Y = B0+B1*(X-Pivot);
} else {
Function Y = B0+B2*(X-Pivot);
}
Plot residual;
Rplot grid;
Data;
1.0000 9.0640
1.1429 9.3975
1.2857 9.2018
1.4286 9.2857
1.5714 8.9093
1.7143 9.3477
1.8571 9.0515
2.0000 8.8722
2.1429 9.3411
2.2857 8.8253
2.4286 8.9658
2.5714 8.4049
2.7143 8.4536
2.8571 8.8517
3.0000 8.8919
3.1429 8.4210
3.2857 8.7708
3.4286 8.6519
3.5714 8.4829
3.7143 8.0907
3.8571 7.9835
4.0000 8.0832
4.1429 8.2473
4.2857 7.5845
4.4286 7.6238
4.5714 7.6233
4.7143 7.5825
4.8571 7.7350
5.0000 7.6635
5.1429 7.6477
5.2857 7.1760
5.4286 7.2312
5.5714 7.1163
5.7143 6.8115
5.8571 6.8880
6.0000 6.7678
6.1429 6.4633
6.2857 6.0894
6.4286 5.7891
6.5714 6.1622
6.7143 5.9032
6.8571 5.8183
7.0000 5.4021
7.1429 5.2677
7.2857 5.3045
7.4286 5.1546
7.5714 4.7516
7.7143 4.8867
7.8571 4.5282
8.0000 4.6656